<template>
	<div class="loginWrap">
		<form>
			<h1>登录</h1>
			<div class="">
				<input type="text" v-model="form.username"/>
				
			</div>
			<div class="">
				<input type="text" v-model="form.password"/>
			</div>
			
			<div class="">
				<button type="button" @click="login">登录</button>
			</div>
		</form>
	</div>
</template>

<script>
	// import network from '@/network'
	import { loginApi } from '@/api/users.js'
	export default {
		name: 'login',
		data() {
			return {
				form: {
					username: '',
					password: ''
				},
				
			}
		},
		methods:{
			async login(){
				// this.$router.push('/')
				// console.log(34, '==========')
				let res = await loginApi({
					data: this.form
				})
				console.log(39, res)
				alert(res.msg)
				if(res.code == '200'){
					localStorage.setItem('token', res.token)
					this.$router.push('/')
				}
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	form{
		margin: 0 auto;
	}
</style>
